﻿@model SmallJob.Model.MConversation
@{
    var displayorder = ViewData["displayorder"] as SmallJob.Model.Order;
    var isbuyer = Convert.ToBoolean(ViewData["isbuyer"]);
    var userid = (int)ViewData["curuserid"];
    var client = (Model.Person1ID == userid ? Model.User2 : Model.User1);
    var host = (Model.Person2ID == userid ? Model.User2 : Model.User1);
}
@using SmallShop.Services.Code;
<div style="border-bottom: solid 1px #cfc1c1; padding: 20px;">
    @if (!displayorder.DisableDetails)
    {
        <a href="@Url.Action("OrderDetails", "Personal", new { cvsid = Model.ShortID })" target="_blank">Go To Details</a>
    }
@*@if (SmallShop.Services.Code.OrderHelper.GetPayerID(displayorder) == userid)
    {
        if (displayorder.Status == (int)OrderStatus.WorkerMarkDone)
        {
        <p>Dịch vụ đã hoàn thành. Mời bạn đánh giá dịch vụ.</p>
            if (displayorder.Rate == null)
            {
        <div class='rateit' id="rateit5"></div>
        <span id="value5"></span>
        <input type="button" class="btn" value="Done" onclick="commitrate(this);" />
            }
            else if (string.IsNullOrWhiteSpace(displayorder.Comment))
            {
        <textarea placeholder="Ý kiến của bạn sau khi sử dụng dịch vụ." style="width: 100%; max-width: 100%;"></textarea>
        <input type="button" class="btn" value="Done" onclick="commitcomment(this);" />
            }
        }
        else if (OrderHelper.IsOrderCanCancel(displayorder))
        {
        <input type="button" class="btn" value="Hủy đơn hàng" onclick="makecancelorder(this);" />
        }
    }
    else
    {
        if (!displayorder.Completed)
        {
        <input type="button" class="btn" value="Hoàn thành" onclick="makedoneorder(this);" />
        }
        else
        {
        <p>Đang chờ khách hàng đánh giá dịch vụ.</p>
        }
    }*@
</div>
@if (ViewData["nextpage"] != null)
{
    <div id="is-page-more"><a data-nextpage="@ViewData["nextpage"]" id="get-next-page" onclick="loadmoremessage(this)">Lấy thêm tin nhắn cũ.</a></div>
}
<div class="conversation-detail-inner">
    @foreach (var item in Model.Messages)
    {
        var sender = (item.SenderID == userid ? host : client);
        <div class="conversation-message">
            <div class="conversation-avatar pull-left">
                <img src="@(string.IsNullOrWhiteSpace(sender.Avatar) ? Url.Content("~/Content/img/blank-avatar.jpg") : sender.Avatar)?w=32&h=32&q=90&format=jpg&mode=crop" />
            </div>
            <div class="conversation-body">
                <p class="inbox-meta">
                    <a   class="inbox-sender" href="/@(string.IsNullOrWhiteSpace(sender.UserName) ? sender.ID.ToString() : sender.UserName)">@sender.Name  </a>
                    <span class="inbox-date">@string.Format("{0:t}", item.Date)</span>
                </p>
                <p class="inbox-message">
                    @item.Content
                </p>
            </div>
        </div>
    }
</div>
<script type="text/javascript">
    $('#rateit5').rateit({ max: 5, step: 1 });
    $('#rateit5').rateit('step', 1);
    $("#rateit5").bind('rated', function (event, value) { $('#value5').text('You\'ve rated it: ' + value); });
    $("#rateit5").bind('reset', function () { $('#value5').text('Rating reset'); });
</script>
